//
//  BCAccountBalanceViewController.m
//  BangcaiBuy
//
//  Created by lsy on 16/6/13.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCAccountBalanceViewController.h"

@implementation BCAccountBalanceViewController

-(void)viewDidLoad {
    [super viewDidLoad];
    [self p_initNavgationBar];
    [self p_initShowAccountBalanceBar];
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    //隐藏导航栏
    self.navigationController.navigationBar.hidden = NO;

    if (!self.rdv_tabBarController.tabBarHidden) {
        [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
    }
}

-(void)viewWillDisappear:(BOOL)animated {
    if (self.rdv_tabBarController.tabBarHidden) {
        [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];
    }
}

#pragma mark - View init
-(void)p_initNavgationBar {
    self.title = @"账户余额";
    self.view.backgroundColor = [UIColor whiteColor];
}

-(void)p_initShowAccountBalanceBar {
    
    CGFloat diamondView_WH = SCREEN_HEIGHT*0.18f;
    UIView *diamondView = [[UIView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-diamondView_WH)*0.5f, SCREEN_HEIGHT*0.07f, diamondView_WH, diamondView_WH)];
    diamondView.backgroundColor = BangcaiGreen;
    diamondView.layer.cornerRadius = diamondView.frame.size.height/2;
    [self.view addSubview:diamondView];
    
    CGFloat diamondImageView_WH = diamondView.frame.size.height*0.7f;
    UIImageView *diamondImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"金币"]];
    diamondImageView.frame = CGRectMake(0, 0, diamondImageView_WH, diamondImageView_WH);
    diamondImageView.backgroundColor = [UIColor clearColor];
    diamondImageView.center = diamondView.center;
    [self.view addSubview:diamondImageView];
    
    UILabel *balanceLable = [[UILabel alloc] initWithFrame:CGRectMake(0, diamondView.frame.origin.y+diamondView.frame.size.height+SCREEN_HEIGHT*0.06f, SCREEN_WIDTH, 56.f)];
    balanceLable.backgroundColor = [UIColor clearColor];
    NSString *balanceString = @"165.50".rmbString;
    NSMutableAttributedString *balanceAttributedString = [[NSMutableAttributedString alloc] initWithString:balanceString];
    UIFont *balanceTextFont = [UIFont boldSystemFontOfSize:54];
    UIFont *rmbTextFont = [UIFont boldSystemFontOfSize:37];
    [balanceAttributedString addAttribute:NSFontAttributeName             //文字字体
                                value:rmbTextFont
                                range:NSMakeRange(0, @"￥".length)];
    [balanceAttributedString addAttribute:NSFontAttributeName             //文字字体
                                value:balanceTextFont
                                range:NSMakeRange(@"￥".length, balanceString.length-1)];
    balanceLable.attributedText = balanceAttributedString;
    balanceLable.textAlignment = NSTextAlignmentCenter;
    balanceLable.textColor = [UIColor colorWithRed:0.937 green:0.400 blue:0.188 alpha:1.000];
    [self.view addSubview:balanceLable];
    
    UILabel *balanceTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, balanceLable.frame.origin.y+balanceLable.frame.size.height+15.f, SCREEN_WIDTH, 20.f)];
    balanceTitleLable.backgroundColor = [UIColor clearColor];
    balanceTitleLable.textColor = [UIColor lightGrayColor];
    balanceTitleLable.textAlignment = NSTextAlignmentCenter;
    balanceTitleLable.font = [UIFont systemFontOfSize:17.f];
    balanceTitleLable.text = @"账户余额";
    [self.view addSubview:balanceTitleLable];
    
    UIButton *cashButton = [UIButton buttonWithType:UIButtonTypeCustom];
    cashButton.frame = CGRectMake(10.f, balanceTitleLable.frame.origin.y+balanceTitleLable.frame.size.height+SCREEN_HEIGHT*0.09f, SCREEN_WIDTH-20.f, 54.f);
    cashButton.layer.cornerRadius = 3.f;
    [cashButton setBackgroundColor:BangcaiGreen];
    [cashButton setTitle:@"提现" forState:UIControlStateNormal];
    [cashButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [cashButton addTarget:self action:@selector(cashAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cashButton];
    
    if (SCREEN_HEIGHT>480.f) {
        UIImageView *logoImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LOGO"]];
        logoImageView.frame = CGRectMake((SCREEN_WIDTH*0.81f)*0.5f, cashButton.frame.origin.y+cashButton.frame.size.height+SCREEN_HEIGHT*0.01f, SCREEN_WIDTH*0.19f, SCREEN_HEIGHT*0.22f);
        logoImageView.backgroundColor = [UIColor clearColor];
        logoImageView.contentMode = UIViewContentModeScaleAspectFit;
        [self.view addSubview:logoImageView];
    }
}

#pragma mark - Private Action
-(void)cashAction:(UIButton *)sender {
    NSLog(@"cash");
}

@end
